Once again rework Win32 window decoration code. Doesn't break #104514. The
authorTor Lillqvist <tml@novell.com>
Sun, 27 Nov 2005 02:58:09 +0000 (02:58 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sun, 27 Nov 2005 02:58:09 +0000 (02:58 +0000)
2005-11-27  Tor Lillqvist  <tml@novell.com>

Once again rework Win32 window decoration code. Doesn't break
#104514. The dialogs in gtk-demo now have the same decorations and
behaviour as on X11. Tried to fix #322516 but it seems very hard
to make the trivial sample program there behave as expected. OTOH,
simply moving the gtk_window_decorate() call in the #322516 sample
program after the call to gtk_widget_show() helps...

* gdk/win32/gdkwindow-win32.c (set_or_clear_style_bits): Revert to
the correct semantics. Each call to gdk_window_set_decorations()
which calls this function is supposed to affect all decorations.

(decorate_based_on_hints): New function, looks at both geometry
hints and type hint and sets window decorations based on
that. Consolidate code from gdk_window_set_geometry_hints() and
gdk_window_set_type_hint() here.

(gdk_window_set_geometry_hints, gdk_window_set_type_hint): Call
decorate_based_on_hints().

ChangeLog
ChangeLog.pre-2-10
gdk/win32/gdkwindow-win32.c

index 6a61448aa365c65f1a0dc23bb8eb0ef5e0aa7ae3..55b9a90361b95f15c10749607ad7c4293d06f204 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,23 @@
 2005-11-27  Tor Lillqvist  <tml@novell.com>
 
+       Once again rework Win32 window decoration code. Doesn't break
+       #104514. The dialogs in gtk-demo now have the same decorations and
+       behaviour as on X11. Tried to fix #322516 but it seems very hard
+       to make the trivial sample program there behave as expected. OTOH,
+       simply moving the gtk_window_decorate() call in the #322516 sample
+       program after the call to gtk_widget_show() helps...
+           
        * gdk/win32/gdkwindow-win32.c (set_or_clear_style_bits): Revert to
-       the correct semantics. (#322516)
-       (gdk_window_set_geometry_hints): Adjust call correspondingly.
+       the correct semantics. Each call to gdk_window_set_decorations()
+       which calls this function is supposed to affect all decorations.
+
+       (decorate_based_on_hints): New function, looks at both geometry
+       hints and type hint and sets window decorations based on
+       that. Consolidate code from gdk_window_set_geometry_hints() and
+       gdk_window_set_type_hint() here.
+
+       (gdk_window_set_geometry_hints, gdk_window_set_type_hint): Call
+       decorate_based_on_hints().
 
 2005-11-25  Dom Lachowicz <cinamod@hotmail.com>
 
index 6a61448aa365c65f1a0dc23bb8eb0ef5e0aa7ae3..55b9a90361b95f15c10749607ad7c4293d06f204 100644 (file)
@@ -1,8 +1,23 @@
 2005-11-27  Tor Lillqvist  <tml@novell.com>
 
+       Once again rework Win32 window decoration code. Doesn't break
+       #104514. The dialogs in gtk-demo now have the same decorations and
+       behaviour as on X11. Tried to fix #322516 but it seems very hard
+       to make the trivial sample program there behave as expected. OTOH,
+       simply moving the gtk_window_decorate() call in the #322516 sample
+       program after the call to gtk_widget_show() helps...
+           
        * gdk/win32/gdkwindow-win32.c (set_or_clear_style_bits): Revert to
-       the correct semantics. (#322516)
-       (gdk_window_set_geometry_hints): Adjust call correspondingly.
+       the correct semantics. Each call to gdk_window_set_decorations()
+       which calls this function is supposed to affect all decorations.
+
+       (decorate_based_on_hints): New function, looks at both geometry
+       hints and type hint and sets window decorations based on
+       that. Consolidate code from gdk_window_set_geometry_hints() and
+       gdk_window_set_type_hint() here.
+
+       (gdk_window_set_geometry_hints, gdk_window_set_type_hint): Call
+       decorate_based_on_hints().
 
 2005-11-25  Dom Lachowicz <cinamod@hotmail.com>
 
index 19c4060d33e58760176a6076b296ec96625bce08..799ab68373a214505bfdb3f66f4f68b4b6f87d6e 100644 (file)
@@ -1590,6 +1590,89 @@ gdk_window_set_urgency_hint (GdkWindow *window,
 #endif
 }
 
+static void
+decorate_based_on_hints (GdkWindow *window)
+{
+  GdkWindowImplWin32 *impl;
+  GdkWMDecoration decoration;
+
+  impl = (GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl;
+
+  if (((GdkWindowObject *) window)->window_type != GDK_WINDOW_TOPLEVEL &&
+      ((GdkWindowObject *) window)->window_type != GDK_WINDOW_DIALOG)
+    return;
+
+  if ((impl->hint_flags & GDK_HINT_MIN_SIZE) &&
+      (impl->hint_flags & GDK_HINT_MAX_SIZE) &&
+      impl->hints.min_width == impl->hints.max_width &&
+      impl->hints.min_height == impl->hints.max_height)
+    {
+      decoration = GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MAXIMIZE;
+      if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
+         impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU ||
+         impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR)
+       decoration |= GDK_DECOR_MINIMIZE;
+      else if (impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN)
+       decoration |= GDK_DECOR_MENU | GDK_DECOR_MINIMIZE;
+
+      gdk_window_set_decorations (window, decoration);
+    }
+  else if (impl->hint_flags & GDK_HINT_MAX_SIZE)
+    {
+      decoration = GDK_DECOR_ALL | GDK_DECOR_MAXIMIZE;
+      if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
+         impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU ||
+         impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR)
+       decoration |= GDK_DECOR_MINIMIZE;
+      gdk_window_set_decorations (window, decoration);
+    }
+  else
+    {
+      switch (impl->type_hint)
+       {
+       case GDK_WINDOW_TYPE_HINT_DIALOG:
+         gdk_window_set_decorations (window,
+                                     GDK_DECOR_ALL |
+                                     GDK_DECOR_MINIMIZE |
+                                     GDK_DECOR_MAXIMIZE);
+         break;
+       case GDK_WINDOW_TYPE_HINT_MENU:
+         gdk_window_set_decorations (window,
+                                     GDK_DECOR_ALL |
+                                     GDK_DECOR_RESIZEH |
+                                     GDK_DECOR_MINIMIZE |
+                                     GDK_DECOR_MAXIMIZE);
+         break;
+       case GDK_WINDOW_TYPE_HINT_TOOLBAR:
+         gdk_window_set_decorations (window,
+                                     GDK_DECOR_ALL |
+                                     GDK_DECOR_MINIMIZE |
+                                     GDK_DECOR_MAXIMIZE);
+         gdk_window_set_skip_taskbar_hint (window, TRUE);
+         break;
+       case GDK_WINDOW_TYPE_HINT_UTILITY:
+         break;
+       case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
+         gdk_window_set_decorations (window,
+                                     GDK_DECOR_ALL |
+                                     GDK_DECOR_RESIZEH |
+                                     GDK_DECOR_MENU |
+                                     GDK_DECOR_MINIMIZE |
+                                     GDK_DECOR_MAXIMIZE);
+         break;
+       case GDK_WINDOW_TYPE_HINT_DOCK:
+         break;
+       case GDK_WINDOW_TYPE_HINT_DESKTOP:
+         break;
+       default:
+         /* Fall thru */
+       case GDK_WINDOW_TYPE_HINT_NORMAL:
+         gdk_window_set_decorations (window, GDK_DECOR_ALL);
+         break;
+       }
+    }
+}
+
 void 
 gdk_window_set_geometry_hints (GdkWindow      *window,
                               GdkGeometry    *geometry,
@@ -1625,23 +1708,6 @@ gdk_window_set_geometry_hints (GdkWindow      *window,
                               geometry->max_width, geometry->max_height));
     }
 
-  if ((geom_mask & GDK_HINT_MIN_SIZE) &&
-      (geom_mask & GDK_HINT_MAX_SIZE) &&
-      geometry->min_width == geometry->max_width &&
-      geometry->min_height == geometry->max_height)
-    gdk_window_set_decorations (window,
-                               GDK_DECOR_ALL |
-                               GDK_DECOR_RESIZEH |
-                               GDK_DECOR_MAXIMIZE);
-  else if (geom_mask & GDK_HINT_MAX_SIZE)
-    {
-      gdk_window_set_decorations (window,
-                                 GDK_DECOR_ALL |
-                                 GDK_DECOR_MAXIMIZE);
-    }
-  else
-    gdk_window_set_decorations (window, GDK_DECOR_ALL);
-
   if (geom_mask & GDK_HINT_BASE_SIZE)
     {
       GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n",
@@ -1664,6 +1730,8 @@ gdk_window_set_geometry_hints (GdkWindow      *window,
     {
       GDK_NOTE (MISC, g_print ("... GRAVITY: %d\n", geometry->win_gravity));
     }
+
+  decorate_based_on_hints (window);
 }
 
 void
@@ -3162,42 +3230,9 @@ gdk_window_set_type_hint (GdkWindow        *window,
   GDK_NOTE (MISC, g_print ("gdk_window_set_type_hint: %p: %d\n",
                           GDK_WINDOW_HWND (window), hint));
 
-  GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->type_hint = hint;
+  ((GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl)->type_hint = hint;
 
-  switch (hint)
-    {
-    case GDK_WINDOW_TYPE_HINT_DIALOG:
-      break;
-    case GDK_WINDOW_TYPE_HINT_MENU:
-      gdk_window_set_decorations (window,
-                                 GDK_DECOR_ALL |
-                                 GDK_DECOR_RESIZEH |
-                                 GDK_DECOR_MINIMIZE |
-                                 GDK_DECOR_MAXIMIZE);
-      break;
-    case GDK_WINDOW_TYPE_HINT_TOOLBAR:
-      gdk_window_set_skip_taskbar_hint (window, TRUE);
-      break;
-    case GDK_WINDOW_TYPE_HINT_UTILITY:
-      break;
-    case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
-      gdk_window_set_decorations (window,
-                                 GDK_DECOR_ALL |
-                                 GDK_DECOR_RESIZEH |
-                                 GDK_DECOR_MENU |
-                                 GDK_DECOR_MINIMIZE |
-                                 GDK_DECOR_MAXIMIZE);
-      break;
-    case GDK_WINDOW_TYPE_HINT_DOCK:
-      break;
-    case GDK_WINDOW_TYPE_HINT_DESKTOP:
-      break;
-    default:
-      g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
-      /* Fall thru */
-    case GDK_WINDOW_TYPE_HINT_NORMAL:
-      break;
-    }
+  decorate_based_on_hints (window);
 }
 
 GdkWindowTypeHint